import request from '@/config/axios'

export interface ServerInfo {
  cpu: Cpu
  mem: Mem
  jvm: Jvm
  sys: Sys
  sysFiles: SysFile[]
}

export interface Cpu {
  cpuNum: number
  used: number
  sys: number
  free: number
}

export interface Mem {
  total: number
  used: number
  free: number
  usage: number
}

export interface Jvm {
  total: number
  used: number
  free: number
  usage: number
  name: string
  version: string
  home: string
  userDir: string
  inputArgs: string
  startTime: string
  runTime: string
}

export interface Sys {
  computerIp: string
  computerName: string
  osName: string
  osArch: string
  userDir: string
}

export interface SysFile {
  total: number
  used: number
  free: number
  usage: number
  dirName: string
  sysTypeName: string
  typeName: string
}

export const getServerInfo = async (): Promise<ServerInfo> => {
  return await request.get({ url: '/infra/monitor/server-info' })
}
